#!/usr/bin/python
# -*- coding: UTF-8 -*-

import cv2
import time


def ph():
    cap = cv2.VideoCapture(0)
    while True:
        # get a frame
        ret, frame = cap.read()
        # show a frame
        cv2.imshow("capture", frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            filename = str(time.clock())
            cv2.imwrite("D:/tmp/{0}.jpg".format(filename), frame)
            break
    cap.release()
    cv2.destroyAllWindows()

# ph()


def ph2():
    cap = cv2.VideoCapture(0)
    # get a frame
    ret, frame = cap.read()
    # show a frame
    cv2.imshow("capture", frame)
    filename = str(time.clock())
    cv2.imwrite("E:/tmp/{0}.jpg".format(filename), frame)
    time.sleep(0.5)
    cap.release()
    cv2.destroyAllWindows()

ph2()

